package com.cx.controller;

import com.cx.pojo.User;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;

/**
 * 这个控制器是用来处理与User一切有关的业务
 */
@RestController
public class UserInfo {
    private List<User> users = new ArrayList<>();
    //判断用户是否登录

    @RequestMapping("isauser")
    public User isAUser(@RequestBody User userInfo) {
        System.out.println("执行到了Hotel");
        if (users.size() > 0) {
            users.remove(0);
        }
        users.add(userInfo);
        return userInfo;
    }

    /**
     *
     * @return 返回当前登录的用户信息
     */
    @RequestMapping("getuser")
    public List<User> getUsers() {
        return users;
    }
    @RequestMapping("deleteUser")
    public void deleteUser(){
        System.out.println("11111111111111");
        if (users.size() > 0) {
            users.remove(0);//清空集合信息
        }
    }
}
